package cn.wolfcode.shop.cloud.service.impl;

import cn.wolfcode.shop.cloud.domain.Good;
import cn.wolfcode.shop.cloud.mapper.GoodMapper;
import cn.wolfcode.shop.cloud.service.IGoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@Service
public class GoodServiceImpl implements IGoodService {
    @Autowired
    private GoodMapper goodMapper;
    @Override
    //调用mapper中的方法去数据库查询数据
    //select*from biao where id in(1,2)
    public List<Good> queryGoods(Set<Long> ids) {
        if (ids!=null && ids.size()>0) {
            //set无法使用for循环遍历数据
            ArrayList arrayList = new ArrayList(ids);
            return  goodMapper.queryGoods(arrayList);
        }
        //返回一个空集合
        return Collections.emptyList();
    }
}
